import sys
pos = 0
total = 0
task = map(int,sys.stdin.readline().split())  
for i in range(1,len(task)):
	dist = task[i] - pos
	if dist > 0:
		total += dist * 6
	else:
		total += dist * -4
	total +=5
	pos = task[i]
print total